package tg.webclient.rj.beans.workorder;

import java.rmi.RemoteException;

import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.system.beans.MultiselectDataBean;
import psdi.webclient.system.controller.Utility;
import psdi.webclient.system.controller.WebClientEvent;

public class SelectWzlyBean extends MultiselectDataBean {

	public synchronized int selectok() throws MXException, RemoteException {
		MboRemote wo = this.app.getAppBean().getMbo(0);
		MboSetRemote mboset = this.app.getDataBean("SELECTWZLY").getMboSet();
		if (!mboset.isEmpty() && mboset.count() > 0) {
			for (int i = 0; i < mboset.count(); i++) {
				MboRemote mbo = mboset.getMbo(i);
				if (mbo.isSelected()) {
					mbo.setValue("PARENT", wo.getString("WONUM"), 11L);
				}
			}
			mboset.save();
			this.app.getDataBean("1379912733891").refreshTable();
			this.app.getAppBean().refreshTable();
			this.app.getAppBean().reloadTable();
			Utility.sendEvent(new WebClientEvent("dialogclose", "SELECTWZLY",
					null, sessionContext));
		} else {
			Utility.sendEvent(new WebClientEvent("dialogclose", app
					.getCurrentPageId(), null, sessionContext));
			return 2;
		}

		Utility.sendEvent(new WebClientEvent("dialogclose", app
				.getCurrentPageId(), null, sessionContext));
		return 1;
	}

}
